﻿using SilverPop.UI.Domain;

namespace SilverPop.UI.Services
{
	public interface INoteDataService
	{
		NotePage GetNotes();
	}

	public class NoteDataService : INoteDataService
	{
		private NotePage _loadedData;

		public NotePage GetNotes()
		{
			if (_loadedData != null) return _loadedData;

			_loadedData = new NotePage 
			{
				Title = "Test note page"
			};

			AddStubNote(0, 0, 200, 50, "Top left note goes here");
			AddStubNote(210, 0, 75, 50, "Next to top left note here with rotation", 30);
			AddStubNote(150, 100, 100, 50, "Rotate me", 15);
			AddStubNote(150, 300, 100, 100, "Resize me to see all the text I contain - this is a super long text label that is being wrapped around in the container box but you won't be able to see it unless you resize me.");
			return _loadedData;
		}

		private Note AddStubNote(int x, int y, int w, int h, string text)
		{
			Note newNote = _loadedData.AddNewNote(0, 0);
			newNote.X = x;
			newNote.Y = y;
			newNote.W = w;
			newNote.H = h;
			newNote.Text = text;
			return newNote;
		}

		private void AddStubNote(int x, int y, int w, int h, string text, int angle)
		{
			Note newNote = AddStubNote(x,y,w,h,text);
			newNote.Angle = angle;
		}
	}
}
